package com.centaline.androidsalesblog.api.sale;

import com.baidu.mapapi.model.LatLng;
import com.centaline.androidsalesblog.api.SaleApi;
import com.centaline.androidsalesblog.model.responseobject.PostListRo;
import com.centanet.framework.interfaces.IResponseListener;

import java.util.Arrays;
import java.util.List;

/**
 * 租售列表
 * Created by guilin on 16/1/26.
 */
public class PostListApi extends SaleApi<PostListRo> {

    private int startIndex = 0;
    private String postType = "s";
    private String type;
    private String region;
    private String scopeId;
    private String round;
    private String subwayId;
    private String stationId;
    private String price;
    private String room;
    private String property = "";
    private String area = "";
    private String fitment = "";
    private String construction = "";
    private String direction = "";
    private String feature;
    private String estCode;
    private double samePrice;
    private LatLng latLng;
    private String schoolId;
    private String staffNo;
    private String postIds;
    private String cestCodes;
    private String sort = "0";
    private String max;
    private String min;
    private String keyword;
    private String beginTime;
    private String endTime;

    public PostListApi(Class<?> tag, Class<PostListRo> aClass, IResponseListener<PostListRo> iResponseListener) {
        super(tag, aClass, iResponseListener);
    }

    /**
     * 重置部分冲突查询条件
     */
    public void reset() {
        region = "";
        scopeId = "";
        round = "";
        subwayId = "";
        stationId = "";
//        estCode = "";
        cestCodes = "";
        latLng = null;
    }

    /**
     * 重置部分筛选
     * 住宅类型
     * 面积
     */
    public void resetOther(String... ignore) {
        if (ignore != null) {
            List<String> ignoreList = Arrays.asList(ignore);
            if (!ignoreList.contains("area")) {
                area = "";
            }
            sort = "";
            property = "";
            fitment = "";
            construction = "";
            direction = "";
            feature = "";
        } else {
            sort = "";
            property = "";
            area = "";
            fitment = "";
            construction = "";
            direction = "";
            feature = "";
        }
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }

    public int getStartIndex() {
        return startIndex;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setPostType(String postType) {
        this.postType = postType;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public void setScopeId(String scopeId) {
        this.scopeId = scopeId;
    }

    public void setRound(String round) {
        this.round = round;
    }

    public void setSubwayId(String subwayId) {
        this.subwayId = subwayId;
    }

    public void setStationId(String stationId) {
        this.stationId = stationId;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public void setRoom(String room) {
        this.room = room;
    }

    public void setProperty(String property) {
        this.property = property;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public void setFitment(String fitment) {
        this.fitment = fitment;
    }

    public void setConstruction(String construction) {
        this.construction = construction;
    }

    public void setDirection(String direction) {
        this.direction = direction;
    }

    public void setFeature(String feature) {
        this.feature = feature;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public void setEstCode(String estCode) {
        this.estCode = estCode;
    }

    public void setSamePrice(double samePrice) {
        this.samePrice = samePrice;
    }

    public void setSchoolId(String schoolId) {
        this.schoolId = schoolId;
    }

    public void setLatLng(LatLng latLng) {
        this.latLng = latLng;
    }

    public void setStaffNo(String staffNo) {
        this.staffNo = staffNo;
    }

    public void setPostIds(String postIds) {
        this.postIds = postIds;
    }

    public void setCestCodes(String cestCodes) {
        this.cestCodes = cestCodes;
    }

    public void setMax(String max) {
        this.max = max;
    }

    public void setMin(String min) {
        this.min = min;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public void setBeginTime(String beginTime) {
        this.beginTime = beginTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    @Override
    protected void setParams() {
        resetParams();
        putParams("startIndex", startIndex);
        putParams("pageCount", 10);
        putParams("postType", postType);
        putStringParams("type", type);
        putStringParams("region", region);
        putStringParams("scopeId", scopeId);
        putStringParams("subwayId", subwayId);
        putStringParams("stationId", stationId);
        putStringParams("price", price);
        putStringParams("room", room);
        putStringParams("sort", sort);
        putStringParams("property", property);
        putStringParams("area", area);
        putStringParams("fitment", fitment);
        putStringParams("construction", construction);
        putStringParams("direction", direction);
        putStringParams("feature", feature);
        putStringParams("estCode", estCode);
        putStringParams("schoolId", schoolId);
        putStringParams("staffNo", staffNo);
        putStringParams("postids", postIds);
        putStringParams("cestcodes", cestCodes);
        putStringParams("min", min);
        putStringParams("max", max);
        if (samePrice > 0) {
            putParams("samePrice", samePrice);
        }
        if (latLng != null) {
            putParams("lat", latLng.latitude);
            putParams("lng", latLng.longitude);
            putStringParams("round", round);
        }
        putStringParams("beginTime", beginTime);
        putStringParams("endTime", endTime);
        putStringParams("keyword", keyword);
    }

    @Override
    protected String getPath() {
        return "Post";
    }
}
